﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using GameEngine.Clients.Silverlight.View.Components;
using GameEngine.Clients.Silverlight.View;
using GameEngine.View.Components;

namespace MySettlers.View.Components
{
    public partial class MyGameUC : UserControl, ISilverlightGameView, IMenuView<string>
    {
        public event OnButtonClickHandler<string> OnExternalActionButtonClick;
        public const string EXITBUTTON = "EXITBUTTON";
        public const string SAVEBUTTON = "SAVEBUTTON";
        public const string OPTIONSBUTTON = "OPTIONSBUTTON";

        private static MyGameUC instance;
        public static MyGameUC Instance
        {
            get{
                return instance;
            }
        }
        public MyGameUC()
        {
            InitializeComponent();
            instance = this;
            saveButton.Tag = SAVEBUTTON;
            optionsButton.Tag = OPTIONSBUTTON;
            exitButton.Tag = EXITBUTTON;
        }


        public void setFPS(int fps) {
            fpsTextBlock.Text = fps + " fps";
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button button = (Button)sender;
            if(OnExternalActionButtonClick!=null)
                OnExternalActionButtonClick((string)button.Tag);
        }

        public void SetLevelView(ILevelView<int, FrameworkElement> map)
        {
            levelContainer.Children.Clear();
            levelContainer.Children.Add(map as UIElement);
        }
    }
}
